;(function(){
  $.ajax({
    url: "data/data2.json", //json文件位置
    type: "get",
    dataType: "json", //返回数据格式为json
    success: function (data2){
      // console.log(data2.legend);
      
      var chartDom = document.getElementById('main2');
      var myChart = echarts.init(chartDom,'dark');
      // var myChart = echarts.init(chartDom);
      var option;
      
      option = {
		  title: {
		    text: '毕业生就业地区分布以及平均工资',
		    left: '8%'
		  },
        background:'',
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            crossStyle: {
              color: '#999'
            }
          }
        },
        toolbox: {
          feature: {
            dataView: { show: true, readOnly: false },
            magicType: { show: true, type: ['line', 'bar'] },
            restore: { show: true },
            saveAsImage: { show: true }
          }
        },
        legend: {
          // data: ['成渝','京津翼','长江中游', '长三角', '珠三角','其他','平均工资']
          data:data2.legend
        },
        xAxis: [
          {
            type: 'category',
            // data: ['2017', '2018', '2019', '2020', '2021', '2022'],
            data:data2.xAxis,
            axisPointer: {
              type: 'shadow'
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            // name: '城市分布',
            name:data2.yleft,
            min: 0,
            max: 100,
            interval: 10,
            axisLabel: {
              formatter: '{value} %'
            }
          },
          {
            type: 'value',
            // name: '平均工资',
            name:data2.yright,
            min: 0,
            max: 3,
            interval: 0.3,
            axisLabel: {
              formatter: '{value} w'
            }
          }
        ],
        series: [
           {
            // name: '成渝',
            name:data2.series.areas[0],
            type: 'bar',
            tooltip: {
              valueFormatter: function (value) {
                return value + ' ml';
              }
            },
            // data: [
            //   6.0, 9.0, 11.0, 11.9, 6.9, 7.9
            // ]
            data:data2.series.number[0]
          },
          {
            // name: '京津翼',
            name:data2.series.areas[1],
            type: 'bar',
            tooltip: {
              valueFormatter: function (value) {
                return value + ' ml';
              }
            },
            // data: [
            //   16.0, 13.0, 11.0, 14.9, 9.9, 8.9
            // ]
            data:data2.series.number[1]
          },
           {
            // name: '长江中游',
            name:data2.series.areas[2],
            type: 'bar',
            tooltip: {
              valueFormatter: function (value) {
                return value + ' ml';
              }
            },
            // data: [
            //   17, 12, 11.0, 11.4, 6.4, 11.9
            // ]
            data:data2.series.number[2]
          },
          {
            // name: '长三角',
             name:data2.series.areas[3],
            type: 'bar',
            tooltip: {
              valueFormatter: function (value) {
                return value + ' ml';
              }
            },
            // data: [
            //   3,8.0, 9.0, 24.3, 19.3, 13.8
            // ]
             data:data2.series.number[3]
          },
           {
            // name: '珠三角',
            name:data2.series.areas[4],
            type: 'bar',
            tooltip: {
              valueFormatter: function (value) {
                return value + ' ml';
              }
            },
            // data: [
            //   4.9, 3, 9.0, 15, 10, 6.0
            // ]
             data:data2.series.number[4]
          },
           {
            // name: '其他',
            name:data2.series.areas[5],
            type: 'bar',
            tooltip: {
              valueFormatter: function (value) {
                return value + ' ml';
              }
            },
            // data: [
            //   2.9, 3, 9.0, 22.4, 47.4, 51.4, 
            // ]
             data:data2.series.number[5]
          },
          {
            // name: '平均工资',
             name:data2.series.areas[6],
            type: 'line',
            yAxisIndex: 1,
            tooltip: {
              valueFormatter: function (value) {
                return value + ' w';
              }
            },
            // data: [0.3, 0.6, 1.0, 1.2, 1.3, 1.6,2.5]
             data:data2.series.number[6]
          }
        ]
      };
      
      option && myChart.setOption(option);
      window.onresize = myChart.resize;
    }
  })
   
})();